import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { Cache } from "../../../cache/Cache";
import { EForce } from "../../../../../Message/Public/EForce";
import { ObjCreate } from "../../common/ObjCreate";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../resource/ImagesConst";
import { RobFlagRankCellRender } from "./render/RobFlagRankCellRender";
import { MuiEvent } from "../../../../../com/mui/events/MuiEvent";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GTabBar } from "../../../../../com/mui/controls/GTabBar";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class RobFlagRankPanel
    
    export  class RobFlagRankPanel extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            this._tabData = [{"name":"tab0", "label": Language.getString(80105)}, {"name":"tab1", "label": Language.getString(80523)}, {"name":"tab2", "label": Language.getString(80524)}];
            super(arg1);
            this.setSize(558, 470);
            this.title = Language.getString(80379);
            this.titleHeight = 27;
            this._btnLeave.addEventListener(flash.events.MouseEvent.CLICK, this.clickLeaveHandler);
            return;
        }

        public updateData(arg1: DataProvider, arg2: DataProvider, arg3: DataProvider): void
        {
            this._allData = arg1;
            this._redData = arg2;
            this._blueData = arg3;
            this.tabChangeHandler(null);
            var loc1=arg2.length;
            var loc2=arg3.length;
            if (Cache.instance.role.entityInfo.force == EForce._EForceTwo) 
            {
                loc1 = arg3.length;
                loc2 = arg2.length;
            }
            this._txtPlayerNum.text = Language.getStringByParam(80529, loc1, loc2);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(20, 63, 520, 354, this);
            this._tab = ObjCreate.createGTabBar(25, 42, this._tabData, 66, 22, this, this.tabChangeHandler);
            ObjCreate.createGTextField(HTMLUtil.addColor(Language.getString(80525), GlobalStyle.yellow), 20, 65, 520, 20, this, null, true);
            ObjCreate.createBg(23, 82, 514, 1, this, ImagesConst.SplitLine);
            this._list = ObjCreate.createTileList(20, 82, 518, 328, this);
            this._list.columnWidth = 514;
            this._list.rowHeight = 20;
            this._list.setStyle("cellRenderer", RobFlagRankCellRender);
            var loc1=GlobalStyle.textFormat2;
            this._txtPlayerNum = ObjCreate.createGTextField("", 24, 428, 200, 20, this, loc1);
            this._btnLeave = ObjCreate.createGButton(Language.getString(80526), 453, 427, 80, 23, this);
            return;
        }

        /* internal  */tabChangeHandler(arg1: MuiEvent): void
        {
            var loc1=this._tab.selectedIndex;
            switch (loc1) 
            {
                case 0:
                {
                    if (this._allData != null) 
                    {
                        this._list.dataProvider = this._allData;
                    }
                    break;
                }
                case 1:
                {
                    if (this._redData != null) 
                    {
                        this._list.dataProvider = this._redData;
                    }
                    break;
                }
                case 2:
                {
                    if (this._blueData != null) 
                    {
                        this._list.dataProvider = this._blueData;
                    }
                    break;
                }
            }
            this._list.drawNow();
            return;
        }

        /* internal  */clickLeaveHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.RobFlagLeaveCopyReq, true));
            return;
        }

        /* internal */ /* var */_tabData: Array<any>;

        /* internal */ /* var */_tab: GTabBar;

        /* internal */ /* var */_txtNames: GTextFiled;

        /* internal */ /* var */_list: GTileList;

        /* internal */ /* var */_txtPlayerNum: GTextFiled;

        /* internal */ /* var */_btnLeave: GButton;

        /* internal */ /* var */_allData: DataProvider;

        /* internal */ /* var */_redData: DataProvider;

        /* internal */ /* var */_blueData: DataProvider;
    }
